/**
 * 
 */
package cz.cuni.mff.abacs.burglar.logics.objects.agents;


/**
 * Goal set of the burglar agent.
 * 
 * - Collecting a treasure and returning to a room.
 * 
 * @author abacs
 *
 */
public class BurglarGoal implements GoalBase {
	
	
	/** Room ID
	 * Changeable property. */
	protected int _aimId = -1;
	
	
	/** 
	 * Changeable property. */
	protected int _itemIdToCollect = -1;
	
	
	/**
	 * A vender that the agent needs to visit. */
	protected int _venderToVisit = -1;
	
	
	// -------------------------------------------------------------------------
	// constructors:
	
	
	/**
	 * 
	 * @param aimId
	 * @param itemIdToCollect
	 */
	public BurglarGoal(int aimId, int itemIdToCollect) {
		this._aimId = aimId;
		this._itemIdToCollect = itemIdToCollect;
	}
	
	
	/**
	 * 
	 * @param other
	 * @param itemIdToCollect
	 */
	protected BurglarGoal(BurglarGoal other) {
		this._aimId = other._aimId;
		this._itemIdToCollect = other._itemIdToCollect;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	/**
	 * Set where the agent has to finish the level.
	 */
	public void setAimId(int roomId) {
		this._aimId = roomId;
	}	
	
	
	/**
	 * Returns the room id, where the burglar has to return.
	 */
	public int getAimId() {
		return this._aimId;
	}
	
	
	/**
	 * Sets the item id, the burglar has to collect.
	 */
	public void setItemIdToCollect(int itemId) {
		this._itemIdToCollect = itemId;
	}
	
	
	/**
	 * Returns the item id, the burglar has to collect.
	 */
	public int getItemIdToCollect() {
		return this._itemIdToCollect;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	@Override
	public void setVenderIdToVisit(int venderToVisit) {
		this._venderToVisit = venderToVisit;
	}
	
	
	@Override
	public void removeVenderToVisit() {
		this._venderToVisit = -1;
	}
	
	
	@Override
	public boolean hasVenderToVisit() {
		return this._venderToVisit != -1;
	}
	
	
	@Override
	public int getVenderIdToVisit() {
		return this._venderToVisit;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	@Override
	public boolean isSatisfied(BaseAgent agent) {
		
		if(agent.isInRoom(this._aimId) && agent.hasItem(_itemIdToCollect))
			return true;
		return false;
	}
	
	
	// -------------------------------------------------------------------------
	
	
	@Override
	public void copyChangeables(GoalBase other) {
		this._aimId = ((BurglarGoal)other)._aimId;
		this._itemIdToCollect = ((BurglarGoal)other)._itemIdToCollect;
	}
	
	
}
